﻿using H2.NET.Web.Pages.SMD.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace H2.NET.Web.Pages.SMD.Service
{
    public static class StoreMasterDataService
    {
        public static bool IsExistDevice(t_StoreMasterData model)
        {
            return (model.MachineDeposit.HasValue && model.MachineDeposit.Value >= 0) || model.NewFitment == "仅调色机申请";
        }

        public static t_StoreMasterData GetByPI(string process, int incident)
        {
            return (t_StoreMasterData._Process == process & t_StoreMasterData._Incident == incident).ListFirst<t_StoreMasterData>(" id desc");
        }
        public static t_StoreMasterData GetByTaskAPI(TaskAPI taskapi)
        {
            return (t_StoreMasterData._Process == taskapi.Process & t_StoreMasterData._Incident == taskapi.Incident).ListFirst<t_StoreMasterData>(" id desc");
        }

        public static t_StoreMasterData GetById(int id)
        {
            return (t_StoreMasterData._ID == id).ListFirst<t_StoreMasterData>(" id desc");
        }
        public static void UpdateFinish(TaskAPI TaskAPI)
        {
            (t_StoreMasterData._Process == TaskAPI.Process & t_StoreMasterData._Incident == TaskAPI.Incident).Edit<t_StoreMasterData>(p =>
            {
                p.Step = "Finish";
            });
        }
    }
}